package test3;

//静态代理模式总结:
//真实对象和代理对象都要实现同一个按口
// 代理对象要代理真实角色
//好处:
//代理对象可以做很多真实对象做不了的事情
// 真实对象专注做自己的事情

public class StacticProxy {
    public static void main(String[] args) {
        weddingcompany weddingcompany = new weddingcompany(new You());
        weddingcompany.HappyMarry();
    }
}

interface Marry {
    //人问四大喜事
    //久早逢甘霖//他乡遇故知/洞房花烛夜/金榜题名时
    void HappyMarry();
}

//真实角色，你去结婚
class You implements Marry {
    @Override
    public void HappyMarry() {
        System.out.println("===============秦老师要结婚了，超开心================");
    }
}

//代理角色，帮助你结婚
//静态代理
class weddingcompany implements Marry {
    private Marry target;

    public weddingcompany(Marry target) {
        this.target = target;
    }

    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void before() {
        System.out.println("HappyMarryBefore");
    }

    private void after() {
        System.out.println("HappyMarryAfter");
    }
}
